/**
 * 
 */
package com.demo.sortcsv;

import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

/**
 * @author zachary.zhang
 *
 */
@Slf4j
public class CSVColumn {

    private List<String> columns = Lists.newArrayList();

    public CSVColumn() {

        try (InputStream in = this.getClass().getClassLoader().getResourceAsStream("csv_column");
                        BufferedReader bufferReader = new BufferedReader(new InputStreamReader(in));) {
            String readLine = bufferReader.readLine();
            columns = Arrays.asList(readLine.split(","));
        } catch (IOException e) {
            log.error("read csv_column failed:{}", e);
        }
    }

    public List<String> getColumns() {
        return columns;
    }
}
